package cn.com.huzo.repository.master.impl;

import cn.com.huzo.model.entities.master.MaterialGroupEntity;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import cn.com.huzo.repository.master.MaterialGroupRepository;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * 材料组数据访问对象。
 *
 * @author 吴旭
 */
@Repository("MaterialGroupRepository")
public class MaterialGroupRepositoryImpl extends GenericRepositoryImpl<MaterialGroupEntity, Long>
        implements MaterialGroupRepository {

    private final String namespace = "cn.com.huzo.repository.master.MaterialGroupRepository";

    /**
     * 构造函数,设置the entity to MaterialGroupRepositoryImpl.class.
     */
    public MaterialGroupRepositoryImpl() {
        super(MaterialGroupEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public MaterialGroupEntity fetchByKey(Long key) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByKey"), key);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer fetchForCount(Map<String, Object> criterion) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForCount"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<MaterialGroupEntity> fetchForPage(Map<String, Object> criterion) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForPage"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Long insert(MaterialGroupEntity instance) {
        getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insert"), instance);
        return instance.getGroupId();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer update(MaterialGroupEntity instance) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "update"), instance);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer delete(Long key) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), key);
    }
}
